﻿namespace ReactionGame
{
    /// <summary>
    /// 测试反应时间小游戏（强制类型转换
    /// </summary>
    internal class Program
    {
        static void Main(string[] args)
        {
            //获取游戏开始时间
            DateTime startTime = DateTime.Now;
            //定义正确/错误次数
            int RightTimes = 0, WrongTimes = 0;
            //执行十次循环
            for (int n = 1; n < 11; n++)
            {
                //随机抽取字母
                Random rnd = new Random();
                int RndNumber = rnd.Next(97, 122);
                Console.WriteLine((char)RndNumber);
                //获取玩家输入并判断对错
                char InputLetter = Console.ReadKey().KeyChar;
                if (InputLetter == (char)RndNumber)
                    RightTimes += 1;
                else
                    WrongTimes += 1;
                //获取游戏结束时间
                DateTime endTime = DateTime.Now;
                TimeSpan timespan = endTime - startTime;
                //打印游戏次数、正确/错误次数、总用时
                Console.Clear();
                Console.WriteLine($"已进行{n}次");
                Console.WriteLine($"错误次数为{WrongTimes}");
                Console.WriteLine($"正确次数为{RightTimes}");
                Console.WriteLine($"用时{timespan.TotalSeconds}秒");
            }
        }
    }
}